/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jlibrarian.desktop;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import jlibrarian.JLibException;

/**
 * This class contains static getter methods for getting properities from Texts.properties 
 * @author MantaEx
 */
public class MyBundle {

    private static final String BUNDLE_PATH = "jlibrarian/desktop/Texts";
    private static ResourceBundle bundle = java.util.ResourceBundle.getBundle(BUNDLE_PATH);

    
    /**
     * This method gets properties from Texts.properties and creates book column names
     * @return String bid, title, authors, quantity, notes
     * @throws JLibException if any problem
     */
    public static String[] getBooksColumnNames() throws JLibException {
        try {
            String[] names = new String[6];
            names[0] = bundle.getString("bidTh");
            names[1] = bundle.getString("titleTh");
            names[2] = bundle.getString("authorsTh");
            names[3] = bundle.getString("quantityTh");
            names[4] = bundle.getString("availableTh");
            names[5] = bundle.getString("notesTh");
            return names;

        } catch (NullPointerException e) {
            throw new JLibException(e);
        } catch (MissingResourceException e) {
            throw new JLibException(e);
        } catch (ClassCastException e) {
            throw new JLibException(e);
        }
    }

    /**
     * This method gets properties from Texts.properties and creates customers column names
     * @return String cid, first name, surname, city, street, telephone
     * @throws JLibException if any problem
     */
    public static String[] getCustomersColumnNames() throws JLibException {
        try {
            String[] names = new String[6];
            names[0] = bundle.getString("cidTh");
            names[1] = bundle.getString("fnTh");
            names[2] = bundle.getString("snTh");
            names[3] = bundle.getString("cityTh");
            names[4] = bundle.getString("streetTh");
            names[5] = bundle.getString("telephoneTh");
            return names;

        } catch (NullPointerException e) {
            throw new JLibException(e);
        } catch (MissingResourceException e) {
            throw new JLibException(e);
        } catch (ClassCastException e) {
            throw new JLibException(e);
        }
    }

    /**
     * This method gets properties from Texts.properties and creates rents column names
     * @return String ID, Kniha, Zakaznik, Datum Vypujcky, Datum vraceni
     * @throws JLibException if any problem
     */
    public static String[] getRentsColumnNames() throws JLibException {
        try {
            String[] names = new String[6];
            names[0] = bundle.getString("ridTh");
            names[1] = bundle.getString("bookTh");
            names[2] = bundle.getString("customerTh");
            names[3] = bundle.getString("dtOutTh");
            names[4] = bundle.getString("dateShouldIn");
            names[5] = bundle.getString("dtInTh");
            return names;

        } catch (NullPointerException e) {
            throw new JLibException(e);
        } catch (MissingResourceException e) {
            throw new JLibException(e);
        } catch (ClassCastException e) {
            throw new JLibException(e);
        }
    }

    
    public static String getProperty(String key) throws JLibException{
        try {
            return bundle.getString(key);
        } catch (NullPointerException e) {
            throw new JLibException(e);
        } catch (MissingResourceException e) {
            throw new JLibException(e);
        } catch (ClassCastException e) {
            throw new JLibException(e);
        }
    }
}
